<?php defined('_JEXEC') or die('Restricted access');

$ordering = ($this->lists['order'] == 'ordering');
$tableName = $this->get('tableName');
JHTML::_('behavior.tooltip');
JHTML::stylesheet('base.css', JURI::root().'/components/com_simplelisting/css/');
?>

<form action="index.php?option=com_simplelisting&controller=fields" method="post" name="adminForm" id="adminForm">
<table class="adminheading">
	<tr>
		<td width="100%" align="right">
		<?php echo JText::_('LABEL_FIELDS_TABLE').': '?>
		</td>
		<td nowrap="nowrap">
			<?php echo $this->selectTableList ?>
		</td>
	</tr>
</table>
	<table class="adminlist" width="100%">
	<thead>
		<tr>
                    <th width="1%"><?php echo '#'; ?></th>
                    <th width="1%"><input type="checkbox" name="toggle" name="" onclick="checkAll(<?php echo count( $this->items ); ?>);" /></th>
                    <th width="70%" class="title"><?php echo JTEXT::_('LABEL_NAME'); ?></th>
                    <th width="5%" nowrap="nowrap" align="center">
                    <?php echo JHTML::_('grid.sort', 'ORDER', 'ordering', $this->lists['order_Dir'], $this->lists['order'] ); ?>
                    <?php if ($ordering) echo JHTML::_('grid.order',  $this->items); ?>
                    </th>
                    <?php if($tableName == 'types' || $tableName == 'categories') : ?>
                    <th width="2%"><?php echo JTEXT::_('LABEL_PUBLISHED'); ?></th>
                   <?php endif; ?>
                    <th width="1%"><?php echo JTEXT::_('LABEL_ID'); ?></th>
                </tr>
	</thead>
    <tbody>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)
	{
		$row = &$this->items[$i];

		$link 	= JRoute::_( 'index.php?option=com_simplelisting&controller=fields&task=edit&cid[]='. $row->id );
                $checked = JHTML::_('grid.id', $i, $row->id );
		$published  = JHTML::_('grid.published', $row, $i );

		?>
		<tr class="<?php echo "row$k"; ?>">
                    <td><?php echo $this->pagination->getRowOffset( $i ); ?></td>
                    <td><?php echo $checked; ?></td>
                    <td><a href="<?php echo $link; ?>" title="<?php echo JText::_( 'TT_EDIT_LISTING' ); ?>"><?php echo $row->name; ?></a></td>


                    <td class="order" nowrap="nowrap">
                        <span><?php echo $this->pagination->orderUpIcon( $i, ($row->position == @$rows[$i-1]->position), 'orderup', 'Move Up', $row->ordering ); ?></span>
                        <span><?php echo $this->pagination->orderDownIcon( $i, $n, ($row->position == @$rows[$i+1]->position),'orderdown', 'Move Down', $row->ordering ); ?></span>

                        <?php $disabled = $ordering ?  '' : 'disabled="disabled"'; ?>

                        <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
                    </td>


                     <?php if($tableName == 'types' || $tableName == 'categories') : ?>
                    <td align="center"><?php echo $published; ?></td>
                    <?php endif; ?>
                    <td align="center"><?php echo $this->escape( $row->id); ?></td>
		</tr>
                    <?php
                    $k = 1 - $k;
                    }
                    ?>
    </tbody>
        <tfoot>
		<td colspan="10">
			<?php echo $this->pagination->getListFooter(); ?>
		</td>
	</tfoot>
	</table>
<input type="hidden" name="option" value="com_simplelisting" />
<input type="hidden" name="view" value="fields" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
<?php echo JHTML::_( 'form.token' ) ?>
</form>
